<?php
$api = app('Dingo\Api\Routing\Router');

$api->version('v1', [
  'namespace'  =>  'Zxf5115\Laravel\Advertising\Controllers\Api'
], function ($api)
{
  $api->group([
    'middleware'  =>  'api.throttle', // 启用节流限制
    'limit'  =>  1000, // 允许次数
    'expires'  =>  1, // 分钟
    'prefix' => 'api' // 接口前缀
  ], function ($api)
  {
    $api->group(['middleware' => ['black.list', 'decrypt.request', 'encrypt.response']], function ($api) {
      // 广告路由组
      $api->group(['prefix' => 'advertising'], function ($api) {
        // 广告路由
        $api->get('select', 'AdvertisingController@select');
        $api->get('view/{id}', 'AdvertisingController@view');

        // 广告路由组
        $api->group(['namespace' => 'Advertising'], function ($api) {
          // 广告详情路由
          $api->group(['prefix' => 'detail'], function ($api) {
            $api->get('data', 'DetailController@data');
          });

          // 广告位路由
          $api->group(['prefix' => 'position'], function ($api) {
            $api->get('data', 'PositionController@data');
          });
        });
      });
    });
  });
});
